#include "box2d_internal.hpp"

static luaL_Reg box2d_core[] =
{
	LUAN(create_world),
	LUAN(clone_world),
	LUAN(world_destroy),
	LUAN(create_body),
	LUAN(world_step),
	LUAN(body_add_circle),
	LUAN(body_pos),
	LUAN(body_orientation),
	{NULL, NULL}
};

static luaL_Reg box2d_core_world[] =
{
	// TODO: gc?
	LUAN2(__gc, world_destroy),
	LUAN2(clone, clone_world),
	{NULL, NULL}
};

int luaopen_box2d_core(lua_State* L)
{

	make_metatable(L, &box2d_core_world_tag, box2d_core_world, 0); // mt
	lua_pushvalue(L, -1); // ... | mt mt
	lua_setfield(L, -2, "__index"); // ... | mt
	lua_pop(L, 1);

	luaL_openlib(L, "box2d_core", box2d_core, 0);

	return 1;
}
